<?php

namespace App\Admin\Controllers;

use App\Admin\Repositories\SmsSendlog;
use Dcat\Admin\Grid;
use Dcat\Admin\Http\Controllers\AdminController;
use Dcat\Admin\Widgets\Card;

class SmsSendlogController extends AdminController
{
    protected $title="发送记录";
    /**
     * Make a grid builder.
     *
     * @return Grid
     */
    protected function grid()
    {
        return Grid::make(new SmsSendlog(), function (Grid $grid) {
            $grid->model()->orderBy('id', 'desc');
            $grid->column('id')->sortable();
            $grid->column('mobile','手机号');
            $grid->column('verify_code');
            $grid->column('content')->display('查看')// 设置按钮名称
            ->expand(function () {
                $card = new Card(null, $this->content );
                return "<div style='padding:10px 10px 0;'>$card </div>";
            });
            $grid->column('sms_status','发送状态')->using([ 0 => '待发送',1=>'发送成功',-1=>'发送失败'])->dot([
                0 => 'primary', // 设置默认颜色，不设置则默认为 default
                1 => 'success',
                -1 => 'danger',
            ]);
            $grid->column('s_time');

            $grid->column('cksms','验证状态')->using([ 1 => '已通过',2=>'未使用',3=>'已失效'])->label([
                1 => 'primary', // 设置默认颜色，不设置则默认为 default
                2 => 'success',
                3 => 'danger',
            ]);
            $grid->column('ip');
            $grid->column('created_at');
            $grid->filter(function (Grid\Filter $filter) {
                // 更改为 panel 布局
                // 展开过滤器
                $filter->expand();
                $filter->panel();
                // 注意切换为panel布局方式时需要重新调整表单字段的宽度
                $filter->equal('mobile','手机号码｜邮箱')->width(3);
            });
            $grid->disableRowSelector();
            //禁用新增按钮
            $grid->disableCreateButton();
            // 禁用过滤器按钮
            $grid->disableFilterButton();
            // 禁用批量删除按钮
            $grid->disableBatchDelete();
            // 禁用显示按钮
            $grid->disableViewButton();
            // 去掉删除
            $grid->disableDeleteButton();
            $grid->disableEditButton();
            $grid->disableActions();
            //显示横向滚动条
            $grid->scrollbarX();
        });
    }
}
